<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>

<%@ page import="com.yaodian100.core.common.utils.ServerValue" %>
<%@ page import="com.yaodian100.ec.member.entity.Member" %>
<%@ page import="org.apache.commons.lang.StringUtils" %>

<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c-rt" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%@ taglib uri="http://www.yaodian100.com/jsp/yaodian100" prefix="yaodian100" %>
<%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles" %>
<%@ taglib uri="/struts-tags" prefix="s" %>

<c-rt:set var="frontContextPath" value='<%=ServerValue.getFrontContextPath()%>' />

<script src="/js/jquery.form.js"></script>
<script language="javascript">
	var dialogObj=$("#dialog");
	$().ready(function(){
		$("#current_location").html('&nbsp;&gt;&nbsp;我的礼品卡&nbsp;-&nbsp;礼品卡充值');
		$("#recharge_li").attr('class','mb-tab-f');
		$("#list_li").removeAttr('class');
		
		dialogObj.dialog({
			bgiframe:true,
			width:260,
			height:150,
			modal:true,
			autoOpen:false
		});
		
		<%--換張圖--%>
		$("#chang_image").click(function(){
			$("#iv").attr("src","${frontContextPath}/servlet/imageValid.jpg?"+Math.random());
		});	

		<%--初使化--%>
		$("#iv").attr("src","${frontContextPath}/servlet/imageValid.jpg?"+Math.random());
		
<c-rt:choose>
	<c-rt:when test="${returnCode==0}">
		$("#showAmount").html('<fmt:formatNumber value="${member.balance.giftcardBalance}" pattern="#####0.0#"/>');
		$("#iv").attr("src","${frontContextPath}/servlet/imageValid.jpg?"+Math.random());
		dialogObj.dialog("open");
	</c-rt:when>
	<c-rt:when test="${returnCode==1}">
		$("#iv").attr("src","${frontContextPath}/servlet/imageValid.jpg?"+Math.random());
		$("#msg01").attr("style","display:block;");
	</c-rt:when>
	<c-rt:when test="${returnCode==2}">
		$("#msg02").attr("style","display:block;");
	</c-rt:when>
	<c-rt:when test="${returnCode==3}">
		$("#msg03").attr("style","display:block;");
	</c-rt:when>
	<c-rt:when test="${returnCode==4}">
		$("#msg04").attr("style","display:block;");
	</c-rt:when>
	<c-rt:when test="${returnCode==5}">
		$("#msg05").attr("style","display:block;");
	</c-rt:when>
</c-rt:choose>
	});
	
	function recharge(){
		var targetForm=$("#mainForm");
		targetForm.ajaxForm({
			url:'<s:url value="/member/myGiftcard/recharge.do"></s:url>',
			target:$("#tab")
		});
		targetForm.submit();
	}
	
	function closeDialog(){
		dialogObj.dialog("close");
	}
	function objToUpperCase(obj) {
		obj.value = obj.value.toUpperCase();
	}
</script>

<form id="mainForm">
<div class="mb-drawmoney-form">
	<div class="d-show">
		<ul>
			<li class="w-1of3"><div><strong>礼品卡卡号：</strong></div></li>
			<li class="w-1of5"><div><input type="text" size="30" name="cardCode" id="cardCode" value="${cardCode}" /><a class="help-link" href="/help/12_use_cards.html#usage" target="_blank">礼品卡使用说明</a></div></li>
			<li class="w-1of3"><div><strong>礼品卡密码：</strong></div></li>
			<li class="w-1of5"><div><input type="text" size="30" name="cardPassword" id="cardPassword" value="${cardPassword}" onblur="objToUpperCase(this);"/></div></li>
			<li class="w-1of3"><div><strong>请输入验证码：</strong></div></li>
			<li class="w-1of5">
				<div class="captcha-box">
					<input type="text" name="checkCode" id="checkCode" size="30" maxlength="6" autocomplete="off" /><img id="iv" name="iv" class="captcha" /><a href="#chImg" id="chang_image">看不清？换张图片</a>
					<span id="msg01" style="display:none;"><span class="msg rn">验证码错误，请重新输入！</span></span>
				</div>
			</li>
		</ul>        
		<p class="btn-box">
			<span id="msg02" style="display:none;"><span class="msg rn">礼品卡号或密码错误，请重新输入！</span></span>
			<span id="msg03" style="display:none;"><span class="msg rn">礼品卡号已过开卡期限！</span></span>
			<span id="msg04" style="display:none;"><span class="msg rn">礼品卡号已被启用！</span></span>
			<span id="msg05" style="display:none;"><span class="msg rn">礼品卡尚未激活，请与客服联系。</span></span> 
			<a href="javascript:recharge();" class="btn-mid">充值</a>
        </p>
	</div>
</div>
</form>

<div id="dialog" title="礼品卡充值" class="dailog-ok-L2">
	<p>礼品卡充值成功。</p>
	<div align="center">
		<span style="text-align:center;"><a href="javascript:closeDialog();" class="btn-mid">确定</a></span>
	</div>
</div>